version: '3'

services:
  config-server:
    image: springcommunity/spring-petclinic-config-server
    container_name: config-server
    deploy:
      resources:
        limits:
          memory: 512M
    healthcheck:
      test: ["CMD", "curl", "-I", "http://config-server:8888"]
      interval: 5s
      timeout: 5s
      retries: 10
    ports:
     - 8888:8888

  discovery-server:
    image: springcommunity/spring-petclinic-discovery-server
    container_name: discovery-server
    deploy:
      resources:
        limits:
          memory: 512M
    healthcheck:
      test: ["CMD", "curl", "-f", "http://discovery-server:8761"]
      interval: 5s
      timeout: 3s
      retries: 10
    depends_on:
      config-server:
        condition: service_healthy
    ports:
     - 8761:8761

  customers-service:
    image: springcommunity/spring-petclinic-customers-service
    container_name: customers-service
    deploy:
      resources:
        limits:
          memory: 512M
    depends_on:
      config-server:
        condition: service_healthy
      discovery-server:
        condition: service_healthy
    ports:
    - 8081:8081

  visits-service:
    image: springcommunity/spring-petclinic-visits-service
    container_name: visits-service
    deploy:
      resources:
        limits:
          memory: 512M
    depends_on:
      config-server:
        condition: service_healthy
      discovery-server:
        condition: service_healthy
    ports:
     - 8082:8082

  vets-service:
    image: springcommunity/spring-petclinic-vets-service
    container_name: vets-service
    deploy:
      resources:
        limits:
          memory: 512M
    depends_on:
      config-server:
        condition: service_healthy
      discovery-server:
        condition: service_healthy
    ports:
     - 8083:8083

  api-gateway:
    image: springcommunity/spring-petclinic-api-gateway
    container_name: api-gateway
    deploy:
      resources:
        limits:
          memory: 512M
    depends_on:
      config-server:
        condition: service_healthy
      discovery-server:
        condition: service_healthy
    ports:
     - 8080:8080

  tracing-server:
    image: openzipkin/zipkin
    container_name: tracing-server
    deploy:
      resources:
        limits:
          memory: 512M
    environment:
    - JAVA_OPTS=-XX:+UnlockExperimentalVMOptions -Djava.security.egd=file:/dev/./urandom
    ports:
     - 9411:9411

  admin-server:
    image: springcommunity/spring-petclinic-admin-server
    container_name: admin-server
    deploy:
      resources:
        limits:
          memory: 512M
    depends_on:
      config-server:
        condition: service_healthy
      discovery-server:
        condition: service_healthy
    ports:
     - 9090:9090

  ## Grafana / Prometheus

  grafana-server:
    build: ./docker/grafana
    container_name: grafana-server
    deploy:
      resources:
        limits:
          memory: 256M
    ports:
    - 3000:3000

  prometheus-server:
    build: ./docker/prometheus
    container_name: prometheus-server
    deploy:
      resources:
        limits:
          memory: 256M
    ports:
    - 9091:9090
